﻿using CloudMailShared;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net.Mail;

namespace UnitTests
{
    
    
    /// <summary>
    ///This is a test class for CloudMailClientTest and is intended
    ///to contain all CloudMailClientTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CloudMailClientTest
    {
        private TestContext testContextInstance;
        private CloudMailClient cloudMailLiveClient;
        private CloudMailClient cloudMailDevClient;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            cloudMailDevClient = new CloudMailClient("cloudmaildev");
            Assert.IsNotNull(cloudMailDevClient);

            cloudMailLiveClient = new CloudMailClient("cloudmaillive", "DefaultEndpointsProtocol=https;AccountName=tfsdata;AccountKey=eREfG8XAErD9Vt8z4+iVW5Ikze4QSfZPe3hY4j55+jEuUStzQSk/frIJ3j6D5mgQ6/eFsu/XGB/ZUrLK3CvMoQ==");
            Assert.IsNotNull(cloudMailLiveClient);
        }
        
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        /// A test for sendMessage
        /// </summary>
        [TestMethod()]
        public void sendMessageToDevTest()
        {    
            SerializableMailMessage mailMessage = new SerializableMailMessage(
                "testfrom@somewhere.com",
                "testto@overther.com",
                "A test",
                "A body"); 
            
            cloudMailDevClient.sendMessage(mailMessage);
            
            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        /// A test for sendMessage
        /// </summary>
        [TestMethod()]
        public void sendMessageToLiveTest()
        {
            SerializableMailMessage mailMessage = new SerializableMailMessage(
                "testfrom@somewhere.com",
                "testto@overther.com",
                "A test",
                "A body");

            cloudMailLiveClient.sendMessage(mailMessage);

            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
    }
}
